﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="record_detail_o_clearing_form.aspx.cs"
    Inherits="form_rtgs_record_detail_o_clearing_form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="<%= ResolveClientUrl("~/css/validationEngine.jquery.css") %>" rel="stylesheet"
        type="text/css" />
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.validationEngine.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/autoNumeric-1.7.5.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/languages/jquery.validationEngine-en.js") %>"
        type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.formatCurrency.js") %>" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $('#<%=txtAmount.ClientID %>').blur(function () {
                $('#<%=txtAmount.ClientID %>').formatCurrency();
            });

            $('#<%=txtAmount.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });

            var isstatus = '<%= Request.Params["status"] %>';
            if (isstatus == "edit") {
                $("#save").hide();
            }
            //$('#<%=txtAmount.ClientID %>').autoNumeric({ aSep: ',', aDec: '.' });
            $("#<%=txtBussinesDay.ClientID %>").datepicker({ showWeek: true, showButtonPanel: true,
                changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy'//, yearRange: '2010:2030'
            });

            // binds form submission and fields to the validation engine
            jQuery("#form1").validationEngine();

            //            jQuery("#form1").submit();
            if ($("#form1").validationEngine('validate')) { }
            else jQuery("#form1").submit();




            $("#save").click(function () {

                var isclearing = '<%= Request.Params["sknbi"] %>';


                if ($("#form1").validationEngine('validate')) {
                    var fromMember = encodeURIComponent($("#<%=ddlDebitParticipant.ClientID %> option:selected").val());
                    var toMember = encodeURIComponent($("#<%=ddlCreditParticipant.ClientID %> option:selected").val());

                    if (fromMember != toMember) {
                        //var typeOutgoing = '<%= Request.Params["typeOutgoing"] %>';
                        //var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o.ashx") %>';
                        var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o_clearing.ashx") %>';
                        var trn = encodeURIComponent($("#<%=ddlTrn.ClientID %> option:selected").text());
                        var accountDebitParticipant = encodeURIComponent($("#<%=ddlDebitParticipant.ClientID %> option:selected").text());
                        var accountCreditParticipant = encodeURIComponent($("#<%=ddlCreditParticipant.ClientID %> option:selected").text());
                        var debitParticipantsClient = encodeURIComponent($('#<%=txtDebitParticipant.ClientID %>').val());
                        var creditParticipantsClient = encodeURIComponent($('#<%=txtCreditParticipant.ClientID %>').val());
                        var amount = encodeURIComponent($('#<%=txtAmount.ClientID %>').val());
                        var currency = encodeURIComponent($('#<%=txtCurrency.ClientID %>').val());
                        var bussinesDay = encodeURIComponent($('#<%=txtBussinesDay.ClientID %>').val());
                        var transactionSubTypeCode = encodeURIComponent($("#<%=ddlTransTypeCode.ClientID %> option:selected").text());
                        var priority = encodeURIComponent($('#<%=txtPriority.ClientID %>').val());
                        var documentstep = encodeURIComponent($('#<%=txtDocumentStep.ClientID %>').val());
                        var commentcharges = encodeURIComponent($('#<%=txtCommentCharges.ClientID %>').val());
                        var id = $('#<%= hfID.ClientID %>').val();
                        var param = '&trn=' + trn
                                                     + '&accountDebitParticipant=' + accountDebitParticipant
                                                     + '&accountCreditParticipant=' + accountCreditParticipant
                                                     + '&debitParticipantsClient=' + debitParticipantsClient
                                                     + '&creditParticipantsClient=' + creditParticipantsClient
                                                     + '&amount=' + amount
                                                     + '&currency=' + currency
                                                     + '&bussinesDay=' + bussinesDay
                                                     + '&transactionSubTypeCode=' + transactionSubTypeCode
                                                     + '&priority=' + priority
                                                     + '&documentstep=' + documentstep
                                                     + '&commentcharges=' + commentcharges
                               ;

                        if (id == 0)
                            CallAjax(handlerUrl, "?method=insert&isclearing=" + isclearing + param);
                        else
                            CallAjax(handlerUrl, "?method=update" + param + "&id=" + id);

                        parent.$('#dialog').dialog("close");

                        setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);
                    }
                    else {
                        alert("Data from member dan to member tidak boleh sama ..");
                    }
                    return false;
                }
            });

            $('#<%=ddlTrn.ClientID %>').change(function () {

                var desc = $("#<%=ddlTrn.ClientID %> option:selected").val();

                $("#<%=txtTrnDesc.ClientID %>").val(desc);

            });

            $('#<%=ddlDebitParticipant.ClientID %>').change(function () {

                var desc = $("#<%=ddlDebitParticipant.ClientID %> option:selected").val();

                $("#<%=txtDebitParticipant.ClientID %>").val(desc);

            });

            $('#<%=ddlCreditParticipant.ClientID %>').change(function () {

                var desc = $("#<%=ddlCreditParticipant.ClientID %> option:selected").val();

                $("#<%=txtCreditParticipant.ClientID %>").val(desc);

            });
        });

    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="pnlGroupBox" runat="server" GroupingText="TRN">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        Trn
                    </td>
                    <td style="padding-left: 120px">
                        <asp:DropDownList ID="ddlTrn" runat="server" CssClass="validate[required]" Width="250px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>
                        Trn Desc.
                    </td>
                    <td style="padding-left: 120px">
                        <asp:TextBox ID="txtTrnDesc" ReadOnly="true" runat="server" Width="500" Rows="1"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <table border="0">
            <tr>
                <td>
                    <asp:Panel ID="Panel1" runat="server" GroupingText="Debit">
                        <table border="0">
                            <tr>
                                <td>
                                    Field
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDebitField" MaxLength="70" ReadOnly="true" Text="53" runat="server"
                                        Width="300" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Panel ID="Panel9" runat="server" GroupingText=":53">
                                        <table cellpadding="0" cellspacing="0" border="0">
                                            <tr>
                                                <td>
                                                    <asp:RadioButton ID="rbA53" runat="server" GroupName="Field" Text="A" />
                                                </td>
                                                <td>
                                                    <asp:RadioButton ID="rbD53" runat="server" GroupName="Field" Text="D" />
                                                </td>
                                                <td style="padding-left: 10px">
                                                    Participant :
                                                    <asp:TextBox ID="txtDebitParticipant" MaxLength="140" ReadOnly="true" runat="server"
                                                        Width="220" Rows="1"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    Account
                                                </td>
                                                <td>
                                                    <asp:DropDownList CssClass="validate[required]" ID="ddlDebitParticipant" runat="server"
                                                        Enabled="true" Width="300px">
                                                    </asp:DropDownList>
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel2" runat="server" GroupingText="Credit">
                        <table border="0">
                            <tr>
                                <td>
                                    Field
                                </td>
                                <td>
                                    <asp:TextBox ID="TextBox3" Text="58" ReadOnly="true" runat="server" Width="300" Rows="1"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Panel ID="Panel10" runat="server" GroupingText=":58">
                                        <table cellpadding="0" cellspacing="0" border="0">
                                            <tr>
                                                <td>
                                                    <asp:RadioButton ID="RadioButton1" runat="server" GroupName="Field" Text="A" />
                                                </td>
                                                <td>
                                                    <asp:RadioButton ID="RadioButton2" runat="server" GroupName="Field" Text="D" />
                                                </td>
                                                <td style="padding-left: 10px">
                                                    Participant :
                                                    <asp:TextBox ID="txtCreditParticipant" MaxLength="140" ReadOnly="true" runat="server"
                                                        Width="220"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    Account
                                                </td>
                                                <td>
                                                    <asp:DropDownList CssClass="validate[required]" ID="ddlCreditParticipant" runat="server"
                                                        Enabled="true" Width="300px">
                                                    </asp:DropDownList>
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="Panel5" runat="server" GroupingText="Amount">
                        <table border="0">
                            <tr>
                                <td>
                                    Amount
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAmount" CssClass="validate[required]" runat="server" Width="300px"
                                        ReadOnly="false"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Currency
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCurrency" Text="IDR" CssClass="validate[required]" MaxLength="3"
                                        runat="server" ReadOnly="false" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Bussines Day
                                </td>
                                <td>
                                    <asp:TextBox ID="txtBussinesDay" CssClass="validate[required]" MaxLength="8" runat="server"
                                        ReadOnly="false" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel6" runat="server" GroupingText="Details">
                        <table border="0">
                            <tr>
                                <td>
                                    Transaction's Type Code
                                </td>
                                <td>
                                    <%--<asp:TextBox ID="txtTransactionSubTypeCode" CssClass="validate[required]" MaxLength="3" ReadOnly="false" runat="server"
                                        Width="300px"></asp:TextBox>--%>
                                    <asp:DropDownList Enabled="false" ID="ddlTransTypeCode" runat="server" Width="200px">
                                        <asp:ListItem Text="300" Value="300"></asp:ListItem>
                                        <asp:ListItem Text="301" Value="301"></asp:ListItem>
                                        <asp:ListItem Text="302" Value="302"></asp:ListItem>
                                        <asp:ListItem Text="310" Value="310"></asp:ListItem>
                                        <asp:ListItem Text="311" Value="311"></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Panel ID="Panel7" runat="server" GroupingText="Priority">
                        <table border="0">
                            <tr>
                                <td>
                                    Priority
                                </td>
                                <td>
                                    <asp:TextBox ID="txtPriority" MaxLength="2" CssClass="validate[required]" runat="server"
                                        ReadOnly="false" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
                <td>
                    <asp:Panel ID="Panel8" runat="server" GroupingText="Draft Details">
                        <table border="0">
                            <tr>
                                <td>
                                    Document Step
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDocumentStep" CssClass="validate[required]" ReadOnly="false"
                                        runat="server" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Comment Charges
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCommentCharges" CssClass="validate[required]" ReadOnly="false"
                                        runat="server" Width="300px"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div style="text-align: right; padding-top: 10px;">
                        <a href="#" id="save" class="dialog_link ui-state-default ui-corner-all" alt="Save"
                            onclick="parent.$('#dialog').dialog('Save');"><span class="ui-icon ui-icon-close">
                            </span>Save</a>&nbsp;<a href="#" id="close" class="dialog_link ui-state-default ui-corner-all"
                                alt="Close" onclick="parent.$('#dialog').dialog('close');"><span class="ui-icon ui-icon-close">
                                </span>Close</a>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:HiddenField ID="hfID" runat="server" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
